import 'package:flutter/material.dart';
import 'package:fzcgx_app/common/adapter_utils.dart';
import 'package:fzcgx_app/common/assets_utils.dart';
import 'package:fzcgx_app/provider/provider_widget.dart';
import 'package:fzcgx_app/ui/base/base_view_model.dart';
import 'package:fzcgx_app/ui/my/worker/view_model/worker_base_info_view_model.dart';
import 'package:fzcgx_app/ui/widget/custom_appbar_widget.dart';

class WorkerBaseInfoPage extends StatefulWidget {
  WorkerBaseInfoPage({Key key}) : super(key: key);

  @override
  _WorkerBaseInfoPageState createState() => _WorkerBaseInfoPageState();
}

class _WorkerBaseInfoPageState extends State<WorkerBaseInfoPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: CustomAppbar(
        title: '基本信息',
      ),
      body: SafeArea(
          child: ProviderWidget<WorkerBaseInfoViewModel>(
        model: WorkerBaseInfoViewModel(),
        onReady: (viewModel) {
          viewModel.requestApi();
        },
        builder: (context, viewModel, child) {
          return SingleChildScrollView(
            child: viewModel.state == ViewState.Success
                ? _buildSuccessWidget(viewModel)
                : Container(),
          );
        },
      )),
    );
  }

  Widget _buildSuccessWidget(WorkerBaseInfoViewModel viewModel) {
    return Container(
      child: Column(
        children: <Widget>[
          SizedBox(
            height: AdapterUtils.getHeight(4),
          ),
          Container(
            height: AdapterUtils.getHeight(38),
            color: Color(0xffEAF7FE),
            child: Center(
              child: Text(
                '注册填写/上传的信息越全面，客户信任度越高',
                style: TextStyle(
                  fontSize: AdapterUtils.getSp(13),
                  color: Color(0xff15A1FF),
                  fontWeight: FontWeight.w500,
                ),
              ),
            ),
          ),
          SizedBox(
            height: AdapterUtils.getHeight(28),
          ),
          Container(
            margin: EdgeInsets.symmetric(horizontal: AdapterUtils.getWidth(15)),
            decoration: BoxDecoration(
                border: Border(
                    bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Text(
                  '姓名',
                  style: TextStyle(
                    fontSize: AdapterUtils.getSp(14),
                    color: Color(0xff606B79),
                    fontWeight: FontWeight.w500,
                  ),
                ),
                TextField(
                  controller: viewModel.nameController,
                  style: TextStyle(
                    fontSize: AdapterUtils.getSp(18),
                    color: Color(0xff3B4859),
                    fontWeight: FontWeight.w500,
                  ),
                  decoration: InputDecoration(
                      contentPadding: EdgeInsets.only(
                          top: AdapterUtils.getHeight(10),
                          bottom: AdapterUtils.getHeight(20)),
                      hintText: '请输入您的姓名',
                      border: InputBorder.none,
                      hintStyle: TextStyle(
                        fontSize: AdapterUtils.getSp(18),
                        color: Color(0xffD7D8DB),
                        fontWeight: FontWeight.w500,
                      )),
                )
              ],
            ),
          ),
          SizedBox(
            height: AdapterUtils.getHeight(24),
          ),
          InkWell(
            onTap: (){
              viewModel.onShowBottomSheet(context);
            },
            child: Container(
              margin:
                  EdgeInsets.symmetric(horizontal: AdapterUtils.getWidth(15)),
              padding: EdgeInsets.only(bottom: AdapterUtils.getHeight(10)),
              decoration: BoxDecoration(
                  border: Border(
                      bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Text(
                    '性别',
                    style: TextStyle(
                      fontSize: AdapterUtils.getSp(14),
                      color: Color(0xff606B79),
                      fontWeight: FontWeight.w500,
                    ),
                  ),
                 Container(
                   height: AdapterUtils.getHeight(54),
                   child:  Row(
                     mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      Text(viewModel.model.sex.isEmpty ? '请选择您的性别':viewModel.model.legalSexStr,
                          style: TextStyle(
                            fontSize: AdapterUtils.getSp(18),
                            color: viewModel.model.sex.isEmpty? Color(0xffD7D8DB):Color(0xff3B4859),
                            fontWeight: FontWeight.w500,
                          )),
                          Image.asset(AssetsUtils.getAssetsImagesPath('arrow_right.png'),width: 
                          AdapterUtils.getWidth(30),height: AdapterUtils.getHeight(30),)
                    ],
                  ),
                 )
                ],
              ),
            ),
          ),
          SizedBox(
            height: AdapterUtils.getHeight(24),
          ),
          Container(
            margin: EdgeInsets.symmetric(horizontal: AdapterUtils.getWidth(15)),
            decoration: BoxDecoration(
                border: Border(
                    bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Text(
                  '专业',
                  style: TextStyle(
                    fontSize: AdapterUtils.getSp(14),
                    color: Color(0xff606B79),
                    fontWeight: FontWeight.w500,
                  ),
                ),
                TextField(
                  controller: viewModel.zhuanyeController,
                  style: TextStyle(
                    fontSize: AdapterUtils.getSp(18),
                    color: Color(0xff3B4859),
                    fontWeight: FontWeight.w500,
                  ),
                  decoration: InputDecoration(
                      contentPadding: EdgeInsets.only(
                          top: AdapterUtils.getHeight(10),
                          bottom: AdapterUtils.getHeight(20)),
                      hintText: '请输入您的专业',
                      border: InputBorder.none,
                      hintStyle: TextStyle(
                        fontSize: AdapterUtils.getSp(18),
                        color: Color(0xffD7D8DB),
                        fontWeight: FontWeight.w500,
                      )),
                )
              ],
            ),
          ),
          SizedBox(
            height: AdapterUtils.getHeight(24),
          ),
          Container(
            margin: EdgeInsets.symmetric(horizontal: AdapterUtils.getWidth(15)),
            decoration: BoxDecoration(
                border: Border(
                    bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Text(
                  '籍贯',
                  style: TextStyle(
                    fontSize: AdapterUtils.getSp(14),
                    color: Color(0xff606B79),
                    fontWeight: FontWeight.w500,
                  ),
                ),
                TextField(
                   controller: viewModel.jiguanController,
                  style: TextStyle(
                    fontSize: AdapterUtils.getSp(18),
                    color: Color(0xff3B4859),
                    fontWeight: FontWeight.w500,
                  ),
                  decoration: InputDecoration(
                      contentPadding: EdgeInsets.only(
                          top: AdapterUtils.getHeight(10),
                          bottom: AdapterUtils.getHeight(20)),
                      hintText: '请输入您的籍贯',
                      border: InputBorder.none,
                      hintStyle: TextStyle(
                        fontSize: AdapterUtils.getSp(18),
                        color: Color(0xffD7D8DB),
                        fontWeight: FontWeight.w500,
                      )),
                )
              ],
            ),
          ),
          SizedBox(
            height: AdapterUtils.getHeight(24),
          ),
          Container(
            margin: EdgeInsets.symmetric(horizontal: AdapterUtils.getWidth(15)),
            decoration: BoxDecoration(
                border: Border(
                    bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Text(
                  '体重',
                  style: TextStyle(
                    fontSize: AdapterUtils.getSp(14),
                    color: Color(0xff606B79),
                    fontWeight: FontWeight.w500,
                  ),
                ),
                TextField(
                   controller: viewModel.tizhongController,
                  keyboardType: TextInputType.numberWithOptions(decimal: true),
                  style: TextStyle(
                    fontSize: AdapterUtils.getSp(18),
                    color: Color(0xff3B4859),
                    fontWeight: FontWeight.w500,
                  ),
                  decoration: InputDecoration(
                      contentPadding: EdgeInsets.only(
                          top: AdapterUtils.getHeight(10),
                          bottom: AdapterUtils.getHeight(20)),
                      hintText: '请输入您的体重',
                      border: InputBorder.none,
                      hintStyle: TextStyle(
                        fontSize: AdapterUtils.getSp(18),
                        color: Color(0xffD7D8DB),
                        fontWeight: FontWeight.w500,
                      )),
                )
              ],
            ),
          ),
          SizedBox(
            height: AdapterUtils.getHeight(24),
          ),
          Container(
            margin: EdgeInsets.symmetric(horizontal: AdapterUtils.getWidth(15)),
            decoration: BoxDecoration(
                border: Border(
                    bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Text(
                  '民族',
                  style: TextStyle(
                    fontSize: AdapterUtils.getSp(14),
                    color: Color(0xff606B79),
                    fontWeight: FontWeight.w500,
                  ),
                ),
                TextField(
                   controller: viewModel.minzuController,
                  style: TextStyle(
                    fontSize: AdapterUtils.getSp(18),
                    color: Color(0xff3B4859),
                    fontWeight: FontWeight.w500,
                  ),
                  decoration: InputDecoration(
                      contentPadding: EdgeInsets.only(
                          top: AdapterUtils.getHeight(10),
                          bottom: AdapterUtils.getHeight(20)),
                      hintText: '请输入您的民族',
                      border: InputBorder.none,
                      hintStyle: TextStyle(
                        fontSize: AdapterUtils.getSp(18),
                        color: Color(0xffD7D8DB),
                        fontWeight: FontWeight.w500,
                      )),
                )
              ],
            ),
          ),
          SizedBox(
            height: AdapterUtils.getHeight(24),
          ),
          Container(
            margin: EdgeInsets.symmetric(horizontal: AdapterUtils.getWidth(15)),
            decoration: BoxDecoration(
                border: Border(
                    bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Text(
                  '工作年限',
                  style: TextStyle(
                    fontSize: AdapterUtils.getSp(14),
                    color: Color(0xff606B79),
                    fontWeight: FontWeight.w500,
                  ),
                ),
                TextField(
                   controller: viewModel.gongzuonianxianController,
                  keyboardType: TextInputType.numberWithOptions(decimal: true),
                  style: TextStyle(
                    fontSize: AdapterUtils.getSp(18),
                    color: Color(0xff3B4859),
                    fontWeight: FontWeight.w500,
                  ),
                  decoration: InputDecoration(
                      contentPadding: EdgeInsets.only(
                          top: AdapterUtils.getHeight(10),
                          bottom: AdapterUtils.getHeight(20)),
                      hintText: '请输入您的工作年限',
                      border: InputBorder.none,
                      hintStyle: TextStyle(
                        fontSize: AdapterUtils.getSp(18),
                        color: Color(0xffD7D8DB),
                        fontWeight: FontWeight.w500,
                      )),
                )
              ],
            ),
          ),
          SizedBox(
            height: AdapterUtils.getHeight(24),
          ),
          Container(
            margin: EdgeInsets.symmetric(horizontal: AdapterUtils.getWidth(15)),
            decoration: BoxDecoration(
                border: Border(
                    bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Text(
                  '政治面貌',
                  style: TextStyle(
                    fontSize: AdapterUtils.getSp(14),
                    color: Color(0xff606B79),
                    fontWeight: FontWeight.w500,
                  ),
                ),
                TextField(
                   controller: viewModel.zhengzhimianmaoController,
                  style: TextStyle(
                    fontSize: AdapterUtils.getSp(18),
                    color: Color(0xff3B4859),
                    fontWeight: FontWeight.w500,
                  ),
                  decoration: InputDecoration(
                      contentPadding: EdgeInsets.only(
                          top: AdapterUtils.getHeight(10),
                          bottom: AdapterUtils.getHeight(20)),
                      hintText: '请输入您的政治面貌',
                      border: InputBorder.none,
                      hintStyle: TextStyle(
                        fontSize: AdapterUtils.getSp(18),
                        color: Color(0xffD7D8DB),
                        fontWeight: FontWeight.w500,
                      )),
                )
              ],
            ),
          ),
          SizedBox(
            height: AdapterUtils.getHeight(24),
          ),
          Container(
            margin: EdgeInsets.symmetric(horizontal: AdapterUtils.getWidth(15)),
            decoration: BoxDecoration(
                border: Border(
                    bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Text(
                  '户口地址',
                  style: TextStyle(
                    fontSize: AdapterUtils.getSp(14),
                    color: Color(0xff606B79),
                    fontWeight: FontWeight.w500,
                  ),
                ),
                TextField(
                   controller: viewModel.hukoudizhiController,
                  style: TextStyle(
                    fontSize: AdapterUtils.getSp(18),
                    color: Color(0xff3B4859),
                    fontWeight: FontWeight.w500,
                  ),
                  decoration: InputDecoration(
                      contentPadding: EdgeInsets.only(
                          top: AdapterUtils.getHeight(10),
                          bottom: AdapterUtils.getHeight(20)),
                      hintText: '请输入您的户口地址',
                      border: InputBorder.none,
                      hintStyle: TextStyle(
                        fontSize: AdapterUtils.getSp(18),
                        color: Color(0xffD7D8DB),
                        fontWeight: FontWeight.w500,
                      )),
                )
              ],
            ),
          ),
          SizedBox(
            height: AdapterUtils.getHeight(24),
          ),
          Container(
            margin: EdgeInsets.symmetric(horizontal: AdapterUtils.getWidth(15)),
            decoration: BoxDecoration(
                border: Border(
                    bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Text(
                  '现住地址',
                  style: TextStyle(
                    fontSize: AdapterUtils.getSp(14),
                    color: Color(0xff606B79),
                    fontWeight: FontWeight.w500,
                  ),
                ),
                TextField(
                   controller: viewModel.xianzhudizhiController,
                  style: TextStyle(
                    fontSize: AdapterUtils.getSp(18),
                    color: Color(0xff3B4859),
                    fontWeight: FontWeight.w500,
                  ),
                  decoration: InputDecoration(
                      contentPadding: EdgeInsets.only(
                          top: AdapterUtils.getHeight(10),
                          bottom: AdapterUtils.getHeight(20)),
                      hintText: '请输入您的现住地址',
                      border: InputBorder.none,
                      hintStyle: TextStyle(
                        fontSize: AdapterUtils.getSp(18),
                        color: Color(0xffD7D8DB),
                        fontWeight: FontWeight.w500,
                      )),
                )
              ],
            ),
          ),
          SizedBox(
            height: AdapterUtils.getHeight(24),
          ),
          Container(
            margin: EdgeInsets.symmetric(horizontal: AdapterUtils.getWidth(15)),
            decoration: BoxDecoration(
                border: Border(
                    bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Text(
                  '紧急联系人',
                  style: TextStyle(
                    fontSize: AdapterUtils.getSp(14),
                    color: Color(0xff606B79),
                    fontWeight: FontWeight.w500,
                  ),
                ),
                TextField(
                   controller: viewModel.jinjilianxirenController,
                  style: TextStyle(
                    fontSize: AdapterUtils.getSp(18),
                    color: Color(0xff3B4859),
                    fontWeight: FontWeight.w500,
                  ),
                  decoration: InputDecoration(
                      contentPadding: EdgeInsets.only(
                          top: AdapterUtils.getHeight(10),
                          bottom: AdapterUtils.getHeight(20)),
                      hintText: '请输入您的紧急联系人',
                      border: InputBorder.none,
                      hintStyle: TextStyle(
                        fontSize: AdapterUtils.getSp(18),
                        color: Color(0xffD7D8DB),
                        fontWeight: FontWeight.w500,
                      )),
                )
              ],
            ),
          ),
          SizedBox(
            height: AdapterUtils.getHeight(24),
          ),
          Container(
            margin: EdgeInsets.symmetric(horizontal: AdapterUtils.getWidth(15)),
            decoration: BoxDecoration(
                border: Border(
                    bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Text(
                  '紧急联系人电话',
                  style: TextStyle(
                    fontSize: AdapterUtils.getSp(14),
                    color: Color(0xff606B79),
                    fontWeight: FontWeight.w500,
                  ),
                ),
                TextField(
                   controller: viewModel.jinjilianxirendianhuaController,
                  keyboardType: TextInputType.numberWithOptions(),
                  style: TextStyle(
                    fontSize: AdapterUtils.getSp(18),
                    color: Color(0xff3B4859),
                    fontWeight: FontWeight.w500,
                  ),
                  decoration: InputDecoration(
                      contentPadding: EdgeInsets.only(
                          top: AdapterUtils.getHeight(10),
                          bottom: AdapterUtils.getHeight(20)),
                      hintText: '请输入您的紧急联系人电话',
                      border: InputBorder.none,
                      hintStyle: TextStyle(
                        fontSize: AdapterUtils.getSp(18),
                        color: Color(0xffD7D8DB),
                        fontWeight: FontWeight.w500,
                      )),
                )
              ],
            ),
          ),
          SizedBox(
            height: AdapterUtils.getHeight(24),
          ),
          InkWell(
            onTap: (){
              viewModel.onShowBottomMaritalStatusSheet(context);
            },
            child: Container(
              margin:
                  EdgeInsets.symmetric(horizontal: AdapterUtils.getWidth(15)),
              padding: EdgeInsets.only(bottom: AdapterUtils.getHeight(10)),
              decoration: BoxDecoration(
                  border: Border(
                      bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Text(
                    '婚姻状态',
                    style: TextStyle(
                      fontSize: AdapterUtils.getSp(14),
                      color: Color(0xff606B79),
                      fontWeight: FontWeight.w500,
                    ),
                  ),
                 Container(
                   height: AdapterUtils.getHeight(54),
                   child:  Row(
                     mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      Text(viewModel.model.hunyinzhuangtai.isEmpty? '请选择您的婚姻状态':viewModel.model.maritalStatusStr,
                          style: TextStyle(
                            fontSize: AdapterUtils.getSp(18),
                            color: viewModel.model.hunyinzhuangtai.isEmpty? Color(0xffD7D8DB):Color(0xff3B4859),
                            fontWeight: FontWeight.w500,
                          )),
                          Image.asset(AssetsUtils.getAssetsImagesPath('arrow_right.png'),width: 
                          AdapterUtils.getWidth(30),height: AdapterUtils.getHeight(30),)
                    ],
                  ),
                 )
                ],
              ),
            ),
          ),
          SizedBox(
            height: AdapterUtils.getHeight(24),
          ),
          InkWell(
            onTap: (){
              viewModel.onShowBottomBirthDateSheet(context);
            },
            child: Container(
              margin:
                  EdgeInsets.symmetric(horizontal: AdapterUtils.getWidth(15)),
              padding: EdgeInsets.only(bottom: AdapterUtils.getHeight(10)),
              decoration: BoxDecoration(
                  border: Border(
                      bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Text(
                    '出生年月',
                    style: TextStyle(
                      fontSize: AdapterUtils.getSp(14),
                      color: Color(0xff606B79),
                      fontWeight: FontWeight.w500,
                    ),
                  ),
                 Container(
                   height: AdapterUtils.getHeight(54),
                   child:  Row(
                     mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      Text(viewModel.model.chushengnianyue.isEmpty? '请选择您的出生年月':viewModel.model.chushengnianyue,
                          style: TextStyle(
                            fontSize: AdapterUtils.getSp(18),
                            color: viewModel.model.chushengnianyue.isEmpty? Color(0xffD7D8DB):Color(0xff3B4859),
                            fontWeight: FontWeight.w500,
                          )),
                          Image.asset(AssetsUtils.getAssetsImagesPath('arrow_right.png'),width: 
                          AdapterUtils.getWidth(30),height: AdapterUtils.getHeight(30),)
                    ],
                  ),
                 )
                ],
              ),
            ),
          ),
           SizedBox(
            height: AdapterUtils.getHeight(24),
          ),
           Container(
                width: AdapterUtils.screenWidth(),
                height: AdapterUtils.getHeight(50),
                 margin: EdgeInsets.all(15),
                child: FlatButton(
                    onPressed:  () {
                     viewModel.onPostApi(context);
                    },
                    disabledColor: Color(0xff15A1FF).withAlpha(80),
                    color: Color(0xff15A1FF),
                    shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.all(Radius.circular(4)),
                    ),
                    child: Text(
                      '保存',
                      style: TextStyle(
                        fontSize: AdapterUtils.getSp(16),
                        color: Colors.white,
                        fontWeight: FontWeight.w500,
                      ),
                    ))),
            SizedBox(
              height: AdapterUtils.getHeight(16),
            ),
        ],
      ),
    );
  }
}
